﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcelToChart
{
    public partial class Form_DateFormat : Form
    {
        public List<string> originTextList { set; get; }
        public List<string> formatTextList { set; get; }

        public Form_DateFormat()
        {
            InitializeComponent();
        }

        public void datagridFillOriginData()
        {
            for(int i = 0; i < originTextList.Count; i++)
            {
                int index = this.dataGridView1.Rows.Add();
                dataGridView1.Rows[index].Cells[0].Value = originTextList[i];
                dataGridView1.Rows[index].Cells[1].Value = formatTextList[i];
            }
        }

        public Form_DateFormat(List<string> origin, List<string> format)
        {
            originTextList = origin;
            formatTextList = format;

            InitializeComponent();

            datagridFillOriginData();
        }

        private void button_end_ok_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void button_end_cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void button_Format_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < originTextList.Count; i++)
            {
                
                string result = System.Text.RegularExpressions.Regex.Replace(dataGridView1.Rows[i].Cells[0].Value.ToString(), @"[^0-9]+", "");
                int num = int.Parse(result);
                Console.WriteLine("get num " + num.ToString());


                // TODO
                //dataGridView1.Rows[i].Cells[0].Value = originTextList[i];
                //dataGridView1.Rows[i].Cells[1].Value = formatTextList[i];
            }
        }
    }
}
